<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" id="form" name="form" action="<?php echo site_url(X_URL.'ads/update');?>" method="post" enctype="multipart/form-data">
                        <?php echo csrf_hidden();?>
                        <input type="hidden" name="ad_id" value="<?php echo $ads['ad_id']; ?>">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 所属城市 </label>
                                <div class="col-sm-9">
                                    <select id="ad_city" name="ad_city">
                                    <?php foreach ($ad_city as $key => $val) {?>
                                        <option value="<?php echo $val['area_id'] ?>" <?php if($val['area_id'] == $ads['ad_city']) echo "selected = selected";?>><?php echo $val['area_name'] ?></option>
                                    <?php } ?>
                                        
                                    </select>
                                   
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 所属频道 </label>
                                <div class="col-sm-9">
                                    <select name="web_category">
                                        <?php foreach ($web_category['web_category'] as $k => $v): ?>
                                        <option value="<?php echo $k; ?>" <?php if($k == $ads['web_category']) echo "selected = selected";?>><?php echo $v ?></option>
                                    <?php endforeach ?>
                                    </select>
                                   
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 图片标题 </label>
                                <div class="col-sm-7">
                                    <input type="text" name="ad_name" id="ad_name" placeholder="图片标题"
                                           class="col-xs-10 col-sm-5" value="<?php echo $ads['ad_name']; ?>">
                                    
                                    <!-- <span class="help-inline">
                                                <span class="middle">网站域名不能为空。</span>
                                            </span> -->
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1">图片链接 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="ad_url" id="ad_url" placeholder="图片链接"
                                           class="col-xs-10 col-sm-5" value="<?php echo $ads['ad_url']; ?>">
                                    
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle"></span>
                                            </span>
                                </div>
                            </div>
                           
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 图片 </label>
                                    <input type="file" name="ad_pic" id="ad_pic" placeholder="图片"
                                           class="col-xs-10 col-sm-5" value="<?php echo $ads['ad_pic']; ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">图片类型为jpg,jpeg,png</span>
                                            </span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 图片类型 </label>
                                <div class="col-sm-9">
                                    <select name="ad_type">
                                    <?php foreach ($ad_type['ad_type'] as $k => $v): ?>
                                        <option value="<?php  echo $k; ?>" <?php if($k == $ads['ad_type']) echo "selected = selected";?>><?php echo $v ?></option>
                                    <?php endforeach ?>
                                        
                                    </select>
                                </div>
                            </div>
                            
                            <div class="space-4"></div>
                           

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    
    
    $(".submit").click(function () {
        var ad_city = $("#ad_city").val();
        var web_category = $("#web_category").val();
        var ad_type = $("#ad_type").val();
        var ad_pic = $("#ad_pic").val();
         if (ad_city == '') {
            bootbox.dialog({
                title: "系统提示",
                message: "城市名称不能为空",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        if (web_category == 0) {
            bootbox.dialog({
                title: "系统提示",
                message: "频道类型不能为空",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        if (ad_type == '') {
            bootbox.dialog({
                title: "系统提示",
                message: "类型不能为空",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        if (ad_pic == '') {
            bootbox.dialog({
                title: "系统提示",
                message: "图片不能为空",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
   

        $('#form').submit();

    })
</script>
</body>
</html>
